from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from meiduo_admin.home import views
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.order import order_views
from meiduo_admin.sku import sku_images_views
from meiduo_admin.sku import sku_views
from meiduo_admin.spu import spu_specs_views
from meiduo_admin.spu import spu_views
from meiduo_admin.system import permission_views
from meiduo_admin.user import user_views




urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$',views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',views.UserIncrementCountView.as_view()),
    url(r'^statistical/day_active/$',views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_orders/$',views.UserDayOrdersCountView.as_view()),
    url(r'^statistical/month_increment/$',views.UserMonthIncrementCountView.as_view()),

    # 商品访问量
    url(r'^statistical/goods_day_views/$',views.GoodVisitCountView.as_view()),

    # 用户查询获取
    url(r'^users/$',user_views.UserDataView.as_view()),

    # 新增商品时的分类显示
    url(r'^skus/categories/$',sku_views.SKUCategoryView.as_view()),

    #把spu添加在商品添加页面中
    url(r'^goods/simple/$', sku_views.SKUGoodSimpleView.as_view()),

    # #### sku的spu规格信息获取。目的: 在添加商品sku的时候,可以将对应的规格信息获取出来
    url(r'^goods/(?P<spu_id>\d+)/specs/$', sku_views.SKUGoodSpecsView.as_view()),

    # 获取新增spu页面的品牌信息
    # url(r'^goods/(?P<brands>\d+)/simple/$',spu_views.SPUBrandSimpleView.as_view()),
    url(r'^goods/brands/simple/$',spu_views.SPUBrandSimpleView.as_view()),

    # 获取spu新增页面的一级分类
    url(r'^goods/channel/categories/$',spu_views.SPUCategoriesOneView.as_view()),

    # 获取spu新增页面的二三级分类
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$', spu_views.SPUCategorySubView.as_view()),

    # 通过fdfs上传图片
    url(r'^goods/images/$',spu_views.SPUImageUploadView.as_view()),

    # 可以获取图片的sku_id,展示在页面中
    url(r'skus/simple/',sku_images_views.SKUImagesViewSet.as_view({"get":"simple"})),

    # 可以获取新增权限的权限类型
    url(r'^permission/content_types/$',permission_views.PermissionContentTypeView.as_view()),

    # 可以获取增加用户组页面的权限表数据
    url(r'^permission/simple/$',permission_views.PermissionSimpleView.as_view()),




]

# 9，permission/groups/ 用户组的数据获取
router = DefaultRouter()
router.register(r'permission/groups',permission_views.GroupPermissionViewSet,base_name="peimission")
urlpatterns += router.urls

# 9，/permission/perms/
router = DefaultRouter()
router.register(r'permission/perms',permission_views.PermissionViewSet,base_name="peimission")
urlpatterns += router.urls

#8,orders
router = DefaultRouter()
router.register(r'orders',order_views.OrderViewSet,base_name="orders")
urlpatterns += router.urls

#6 specs/options可以获取规格选项所有的数据，展示在页面中
router = DefaultRouter()
router.register(r'specs/options',spu_specs_views.SpecsOptionViewSet,base_name="specsoption")
urlpatterns += router.urls

# 7，可以获取所有的图片信息，展示在管理员页面中
router = DefaultRouter()
router.register(r'skus/images',sku_images_views.SKUImagesViewSet,base_name="images")
urlpatterns += router.urls


#5，可以编辑视图，获取spu的规格表的信息，展示在页面中
router = DefaultRouter()
router.register(r'goods/specs',spu_specs_views.SPUspecsViewSet,base_name="goodsspecs")
urlpatterns += router.urls


#4,spu 视图集，因为获取数据后，必然涉及增删改查，所以直接用视图集
router = DefaultRouter()
router.register(r'goods',spu_views.SPUViewSet,base_name="goods")
urlpatterns += router.urls

# 视图集路由，获取商品sku列表数据
#3,sku
router = DefaultRouter()
router.register(r'skus',sku_views.SKUViewSet,base_name="skus")
urlpatterns += router.urls




